﻿using Inovout.Data.Domain;
using KuaJing.Security.Domain;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace KuaJing.Organization.Domain
{
    partial class Position : DataObject
    {
        public Position(){
            this.Organizations = new HashSet<OrganizationUnit>();

        }
       
        private string name;
        [AjaxValidation("CheckName", "Position", ErrorMessage = "不能有名称相同的岗位",AdditionalFields="Id")] 
        [DataProperty("名称", DataType.Text, null, true, 2, 50)]
        public virtual string Name
        {
            get { return this.name; }
            set {
                this.name = value;
                this.Role = new Role() { Name = value, ReserveRole = ReserveRole.Position }; }
        }
        [DataProperty("别名", DataType.Text, null, false, 1, 50)]
        public virtual string ShortName { get; set; }
        public virtual OrganizationUnit Company { get; set; }
        public virtual ReservePosition Reserve { get; set; }
        public virtual ISet<OrganizationUnit> Organizations { get; set; }
        public virtual ISet<Employee> Employees { get; set; }
        public virtual Role Role { get; set; }
    }
}
